import 'package:consumer/consumer.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:ruitmentapp/core/extension/int_extension.dart';
import 'package:ruitmentapp/personnel/model/zj_home_model.dart';
import 'package:ruitmentapp/personnel/widget/zj_home_content_title_card.dart';
import 'package:ruitmentapp/personnel/widget/zj_home_content_job_description.dart';
import 'package:ruitmentapp/personnel/widget/zj_home_content_company_details.dart';
import 'package:ruitmentapp/personnel/widget/zj_home_content_duty_station.dart';
import 'package:ruitmentapp/personnel/model/zj_job_details_model.dart';
import 'package:ruitmentapp/personnel/request/zj_job_details_requet.dart';
import 'package:ruitmentapp/core/shared/size_fit.dart';

class ZJHomeListDetailContent extends StatelessWidget {

  final ZJHomePositionModel _positionModel;
  ZJHomeListDetailContent(this._positionModel);

  @override
  Widget build(BuildContext context) {
    backgroundColor: const Color(0xFFF3F5F7);
    return FutureBuilder(
          future: ZJJobDetailRequest.getJobDetailData(_positionModel.id),
          builder: (BuildContext context,
              AsyncSnapshot<ZJJobDetailsModel> snapshot) {

            if (!snapshot.hasData) return const Center(child: CircularProgressIndicator());
            if (snapshot.error != null) return const Center(child: Text("请求失败"),);

            ZJJobDetailsModel categories = snapshot.data;
            return Column(
              children: [
                Expanded(child:
                  SingleChildScrollView(
                    //滑动的方向 Axis.vertical为垂直方向滑动，Axis.horizontal 为水平方向
                    scrollDirection: Axis.vertical,
                    //true 滑动到底部
                    reverse: false,
                    // padding: const EdgeInsets.only(bottom: 100),
                    ////滑动到底部回弹效果
                    physics: const BouncingScrollPhysics(),
                    child: Container(
                      color: const Color(0xFFF3F5F7),
                      child: Column(
                        children: [
                          ZJHomeContentTitleCard(categories),
                          ZJHomeContentJobdescriptionCard(categories),
                          ZJHomeContentCompanyDetailsCard(categories),
                          ZJHomeContentDutyStationCard(categories),
                        ],
                      ),
                    ),
                  ),
                ),
                Container(
                  height: 60+ZJSizeFit.bottomHeight,
                  color: Colors.white,
                  child: Column(
                    children: [
                      Container(
                        height: 60,
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Padding(
                              padding: const EdgeInsets.only(left: 20),
                              child: MaterialButton(
                                elevation: 0,
                                color: const Color(0xFFF3F5F7),
                                minWidth:40,
                                // padding: const EdgeInsetsDirectional.only(start: 0,end: 10),
                                child: categories.collectionPosition == 0 ? Image.asset('assets/images/home/homeCollection.png',width: 18, height: 18): Image.asset('assets/images/home/homeCollected.png',width: 18, height: 18),
                                onPressed: () => {

                                },
                              ),
                            ),
                            Expanded(child:
                              Padding(
                                padding: const EdgeInsets.only(left: 15),
                                child: MaterialButton(
                                  elevation: 0,
                                  shape: const RoundedRectangleBorder(side: BorderSide.none,borderRadius: BorderRadius.all(Radius.circular(5))),
                                  color: const Color(0xFF5D55FC),
                                  minWidth:40,
                                  // padding: const EdgeInsetsDirectional.only(start: 0,end: 10),
                                  child: const Text('投递简历',style: TextStyle(color: Colors.white),),
                                  onPressed: () => {

                                  },
                                ),
                              ),
                            ),
                            Expanded(child:
                              Padding(
                                padding: const EdgeInsets.only(left: 15,right: 20),
                                child: MaterialButton(
                                  elevation: 0,
                                  shape: const RoundedRectangleBorder(side: BorderSide(color: Color(0xFF5D55FC),width: 1,style: BorderStyle.solid),borderRadius: BorderRadius.all(Radius.circular(5))),
                                  color: const Color(0xFFF3F5F7),
                                  minWidth:40,
                                  // padding: const EdgeInsetsDirectional.only(start: 0,end: 10),
                                  child: const Text('立即沟通',style: TextStyle(color: Color(0xFF5D55FC)),),
                                  onPressed: () => {

                                  },
                                ),
                              ),
                            ),
                          ],
                        ),
                      ),
                      Container(
                        height: ZJSizeFit.bottomHeight,
                      ),
                      // Consumer(builder: builder)
                    ],
                  ),
                ),
              ],
            );
          }
      );
  }


}
